#include "StdAfx.h"
#include "VolTrackbar.h"
#include "TPPlayer.h"

LRESULT CVolTrackbar::OnLButtonDown(UINT uMsg,
									WPARAM wParam,
									LPARAM lParam,
									BOOL& bHandled)
{
	DefWindowProc(uMsg, wParam, lParam);
	bHandled = TRUE;

	int		iPos	= GetPos();
	WORD	wVol	= USHRT_MAX / 100 * (WORD)iPos;
	DWORD	dwVol	= MAKELONG(wVol, wVol);
	CTPPlayer::SetVolume(dwVol);

	return S_OK;
}

LRESULT CVolTrackbar::OnLButtonUp(UINT uMsg,
								  WPARAM wParam,
								  LPARAM lParam,
								  BOOL& bHandled)
{
	DefWindowProc(uMsg, wParam, lParam);
	bHandled = TRUE;

	int		iPos	= GetPos();
	WORD	wVol	= USHRT_MAX / 100 * (WORD)iPos;
	DWORD	dwVol	= MAKELONG(wVol, wVol);
	CTPPlayer::SetVolume(dwVol);

	return S_OK;
}

LRESULT CVolTrackbar::OnMouseMove(UINT uMsg,
								  WPARAM wParam,
								  LPARAM lParam,
								  BOOL& bHandled)
{
	DefWindowProc(uMsg, wParam, lParam);
	bHandled = TRUE;

	if ( 0 != (wParam & MK_LBUTTON) )
	{
		int		iPos	= GetPos();
		WORD	wVol	= USHRT_MAX / 100 * (WORD)iPos;
		DWORD	dwVol	= MAKELONG(wVol, wVol);
		CTPPlayer::SetVolume(dwVol);
	}

	return S_OK;
}
